export GTEST_COLOR=1

ROOT=$(shell pwd)
PANDA_DIR=${ROOT}/arkcompiler/runtime_core/static_core
BUILD_DIR=${ROOT}/build
PRESET=default
TEST_LIST=${ROOT}/tests/testlist

.PHONY: configure ninja_all all clean ninja_clean ninja_tests clean_third_party remove_build full_clean u_runner_help u_runner_ets_cts_gen u_runner_ets_cts u_runner_astchecker u_runner_runtime

all: ninja_all

clean: ninja_clean

configure: ${BUILD_DIR}/build.ninja
	
${BUILD_DIR}/build.ninja:
	(cd ${PANDA_DIR} && cmake --preset=${PRESET})

ninja_all: configure
	(cd ${BUILD_DIR} && ninja all)

ninja_clean:
	(cd ${BUILD_DIR} && ninja clean)

ninja_tests: build
	(cd ${BUILD_DIR} && ninja tests)

clean_third_party:
	rm -rf ${PANDA_DIR}/third_party

remove_build:
	rm -rf ${BUILD_DIR}

full_clean: clean_third_party remove_build

full_rebuild: full_clean build


u_runner_help:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--help | bat -p -l man

u_runner_ets_cts_gen:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--ets-cts \
		--generate-only \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives

u_runner_ets_cts:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--ets-cts \
		--force-generate \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives

u_runner_ets_cts_testlist:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--ets-cts \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives \
		--skip-test-lists \
		--test-list=${TEST_LIST}

u_runner_astchecker:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--astchecker \
		--no-js \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives

u_runner_astchecker_testlist:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--astchecker \
		--no-js \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives \
		--skip-test-lists \
		--test-list=${TEST_LIST}

u_runner_parser:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--parser \
		--no-js \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives

u_runner_parser_testlist:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--parser \
		--no-js \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives \
		--skip-test-lists \
		--test-list=${TEST_LIST}

u_runner_runtime:
	arkcompiler/runtime_core/static_core/tests/tests-u-runner/runner.sh \
		--ets-runtime \
		--no-js \
		--timeout=100 \
		--force-generate \
		--show-progress \
		--build-dir=${BUILD_DIR} \
		--processes=all \
		--work-dir=${BUILD_DIR}/archives


